$(function(){
    init();
    if(jQuery.browser.msie&&jQuery.browser.version=="7.0"){
		$(window).resize(onResize);
    	onResize();    
    }
    function onResize(){
    	var height = $("body").height();
    	$("#center").height(height-$("#top").height()-$("#bottom").height()-10);
    }
    onResizeLeft();
    function onResizeLeft(){
    	var height = $(this).height();
    	var oheight = $(this).not("#searchreturn").height();
    	$("#searchreturn").height(height-oheight);
    }    
})

function init() {
	var yMap = new YMap({
				mapDiv : 'map',
				searchDiv : 'googlesearch',
				addPointDiv : 'addPointDiv',
				typesDiv : "mainsubtype",
				searchResult:"searchreturn"
			});
	var yEarth = new YEarth({
		div:"earth"
	});
	$("#tip").click(function(){
		$("#left").toggle();
		var w=$("#content").css("margin-left");
		var shown = (w!="0px");
		if(shown){
			$("#content").css("margin-left","0px");
			$(this).css("background","url(image/tip.png)")
		}else{
			$("#content").css("margin-left","305px");
			$(this).css("background","url(image/tipl.png)")
		}
		//手动调用设置地图大小的事件
		google.maps.event.trigger(yMap.map, 'resize'); 
	});
	
	$("#switchMapDiv").click(function(){
		$("#map,#earth").toggle();
		if(!yEarth.earth){
			yEarth.loadEarthPage();
		}
	});
	$("#switchMapDiv").css("background-image","url(image/point.png)").css("width","40px").css("height","30px");
}